import * as React from 'react'
import SubjectiveQuizBody from './subjective-quiz/SubjectiveQuizBody';
import BasicQuizBody from './basic-quiz/BasicQuizBody';
import SingleLanguageOnlineCodingBody from './single-language-online/SingleLanguageOnlineCodingBody';
import { PageHeader } from 'antd/es';
import SimpleCodingQuizBody from './simple-coding-quiz/SimpleCodingQuizBody';
import { connect } from 'react-redux';
import QuizSubmissionSummary from './ logic-quiz/QuizSubmissionSummary';
import LogicQuizBody from './ logic-quiz/LogicQuizBody';

class AssignmentBody extends React.Component<any>{

    renderComponent = () => {
        const { type } = this.props

        switch (type) {
            case 'SUBJECTIVE_QUIZ': {
                return <SubjectiveQuizBody {...this.props} />
            }
            case 'BASIC_QUIZ': {
                return <BasicQuizBody {...this.props} />
            }
            case 'ONLINE_LANGUAGE_QUIZ': {
                return <SingleLanguageOnlineCodingBody {...this.props} />
            }
            case 'SIMPLE_CODING_QUIZ': {
                return <SimpleCodingQuizBody  {...this.props} />
            }
            case 'LOGIC_QUIZ': {
                return <QuizSubmissionSummary  {...this.props}
                    updateRouteData={this.props.updateRouteData} />
            }
            case 'LOGIC_QUIZ_DETAIL': {
                return <LogicQuizBody {...this.props} />
            }
            default:
                return ""
        }
    }

    render() {
        const { taskTitle } = this.props
        return <div>
            <PageHeader
                title=''
                onBack={() => this.props.updateRouteData({
                    type: 'TASK_DETAIL',
                    params: { ...this.props }
                })}
                subTitle={`所属任务卡: ${taskTitle}`}
            />
            {this.renderComponent()}
        </div>
    }
}
export default connect()((AssignmentBody))